var ajax = function(info){
	if(window.XMLHttpRequest){
		var xhr = new XMLHttpRequest();	
	}else{
		var xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var url = info.url;
	var type = info.type||"GET";
	var data = info.data||"";
	
	if(type=="GET"){
		xhr.open("GET",url,true);
		xhr.send();
	}else{
		xhr.open("POST",url,true);
		xhr.setRequestHeader("myHeader","myvalue");
		xhr.send(data);
	}
	
	xhr.onload = function(){
		if(info.success){
			info.success(xhr.responseText);
		}
	}
}

var post = function(url,data,success) {
    var xhr = new XMLHttpRequest();
    xhr.open("POST", url, true);
    xhr.setRequestHeader("content-type", "application/json");
    xhr.send(data);

    xhr.onreadystatechange = function() {
      if (xhr.readyState == 4) {
        if (xhr.status == 200) {
          success && success(JSON.parse(xhr.responseText));
        } else {
          console.error(xhr.status, xhr.statusText);
        }
      }
    }
    return xhr;
  };
  
var data = JSON.stringify({})


var get = function(url,success) {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", url, true);
    xhr.send();
    xhr.onreadystatechange = function() {
      if (xhr.readyState == 4) {
        if (xhr.status == 200) {
          success && success(JSON.parse(xhr.responseText));
        } else {
          console.error(xhr.status, xhr.statusText);
        }
      }
    }
    return xhr;
  };